<h2><?php echo $data->get('title'); ?></h2>
<div id="memory">
    <?php if (count($data->get('messages', '/', array())) > 0): ?>
    <table>
        <tr>
            <th>No.</th>
            <th>Message</th>
            <th>Average per item</th>
            <th>Count</th>
            <th>Total memory</th>
        </tr>
        <?php $index = 0; ?>
        <?php $totalMemory = 0; ?>
        <?php $totalCount = 0; ?>
        <?php foreach ($data->get('messages') as $message=>$info): ?>
        <?php $totalMemory += $info['memory']; ?>
        <?php $totalCount += $info['count']; ?>
        <?php $index++; ?>
        <tr>
            <td><?php echo $index; ?>.</td>
            <td><?php echo htmlspecialchars($message); ?></td>
            <td><?php echo \DebugComponent\Renderer\Humanize::capacity(ceil(($info['memory'] * 1024) / $info['count']));?></td>
            <td><?php echo $info['count']; ?>x</td>
            <td><?php echo \DebugComponent\Renderer\Humanize::capacity($info['memory'] * 1024);?></td>
        </tr>
        <?php endforeach; ?>
        <tr>
            <th colspan="3">Total</th>
            <th><?php echo $totalCount; ?>x</th>
            <th><?php echo \DebugComponent\Renderer\Humanize::capacity($totalMemory * 1024); ?></th>
        </tr>
    </table>
    <?php else: ?>
    <span class="noMessages">No memory messages</span>
    <?php endif; ?>
</div>